Skip to content

Accept high-precision matrix storage in native splat sorting - #1894

Merged
bkaradzic-microsoft merged 6 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/native-splat-matrix-storage
Oct 1, 2026
Merged

bkaradzic-microsoft merged 6 commits into
BabylonJS:masterfrom
bkaradzic-microsoft:pr/native-splat-matrix-storage

Conversation

@bkaradzic-microsoft

Copy link
Copy Markdown
Member

Summary

sortSplats assumes the matrix's _m storage is a Float32Array, but released Babylon.js uses ordinary number arrays in high-precision matrix mode. Read the three numeric view-direction components through indexed object properties instead.

This is matrix-storage compatibility, not a change to the sorting algorithm or arithmetic precision.

Independence and coordination

Based directly on upstream master at 2a9dc944, with unchanged dependency pins and the published Babylon.js 9.21.2 contract. No protocol, engine-option, reference, or tolerance changes.

#1883 independently replaces the sorting algorithm. This PR intentionally leaves that algorithm alone; please retain the storage-compatibility hunk when combining the two. It can land before or after that rewrite.

Validation

  • A NativeOptimizations regression covers Float32Array and ordinary number-array matrices, both handedness settings, all three nonzero view-direction components, and empty/single/multiple splat inputs.
  • The original implementation fails with Invalid argument on the ordinary array; the extracted fix passes.
  • Stock Windows x64 / Chakra / Release UnitTests build and targeted test pass. The test explicitly skips when NativeOptimizations is disabled.

Copilot AI lite review requested due to automatic review settings September 18, 2026 22:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

Review effort: Lite
Findings: 3 Medium severity · 1 Low severity

Open (4)
What changed in this PR

Adds matrix-storage compatibility to NativeOptimizations’ sortSplats so it can read Babylon.js model-view matrices stored as either Float32Array or ordinary JS number arrays (high-precision mode), and validates this behavior with a new unit test.

Changes:

  • Read view-direction components from modelView._m via indexed object property access instead of assuming Float32Array.
  • Add a regression unit test covering typed-array vs number-array matrices, both handedness settings, and multiple/single/empty splat inputs.
  • Wire the new test into the UnitTests target and conditionally link NativeOptimizations when enabled.
File Description
Plugins/​NativeOptimizations/​Source/​NativeOptimizations.cpp Makes sortSplats accept both typed-array and number-array matrix storage by reading _m[2/6/10] via Get.
Apps/​UnitTests/​Source/​Tests.NativeOptimizations.cpp Adds a regression test ensuring matrix storage variations no longer throw and produce stable ordering.
Apps/​UnitTests/​CMakeLists.txt Adds the new test source and conditionally links/enables NativeOptimizations for the UnitTests target.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread Apps/UnitTests/Source/Tests.NativeOptimizations.cpp Outdated
Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp Outdated
Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp
Comment thread Apps/UnitTests/Source/Tests.NativeOptimizations.cpp

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread Apps/UnitTests/Source/Tests.NativeOptimizations.cpp
Comment thread Apps/UnitTests/Source/Tests.NativeOptimizations.cpp
Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp
Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp Outdated
@bkaradzic-microsoft

Copy link
Copy Markdown
Member Author

Second-round Copilot follow-up is pushed as cc7cc3a: explicit checks for missing/non-numeric matrix coefficients, 18 regression cases, GoogleTest failure reporting before the worker-timeout hard exit, and an explanation of the algorithm-independent unique-depth ordering oracle. All four new threads are addressed and resolved.

The red MacOS_Installation job on df90da7 is an infrastructure failure before source compilation: GitHub HTTPS connection timeouts while cloning bimg and bx, including the built-in retry. No compiler or unit-test failure was reported. The new head triggers fresh CI, so I am not also retrying the obsolete run or changing dependency pins/build logic to mask the network outage.

Balanced re-review remains pending: the API previously accepted but ignored the effort override and launched Lite. I am not claiming a Balanced review or repeatedly requesting Lite as a substitute.

@bkaradzic-microsoft
bkaradzic-microsoft requested a balanced review from Copilot September 18, 2026 23:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp
Comment thread Plugins/NativeOptimizations/Source/NativeOptimizations.cpp
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the pr/native-splat-matrix-storage branch from cc7cc3a to 7ee8c2e Compare September 22, 2026 20:05
bkaradzic-microsoft added a commit to bkaradzic-microsoft/BabylonNative that referenced this pull request Sep 30, 2026
Review-Group: E4
Source: PR BabylonJS#1894
Squashed final review changes, including regressions and review follow-ups.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
bkaradzic-microsoft and others added 6 commits October 1, 2026 09:39
Read the three view-direction components through numeric properties so
released Babylon.js high-precision matrix storage works alongside Float32Array.
Keep the sorting algorithm and arithmetic unchanged.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Keep Float32Array and ordinary Array support while reporting an actionable
TypeError for unsupported storage. Cover invalid inputs and explain why the
runtime-worker timeout must avoid joining a stuck thread.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Validate the three matrix coefficients before numeric conversion and cover
missing and nonnumeric elements. Report worker timeouts through GoogleTest
before the necessary nonzero hard exit. Explain the unique-depth ordering
oracle instead of duplicating the sorting implementation in the test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 60c2ec68-6de1-445d-9fc9-b699db737eae
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d35d0a8b-b073-4f2a-bbd3-a0b1d3584305
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d35d0a8b-b073-4f2a-bbd3-a0b1d3584305
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d35d0a8b-b073-4f2a-bbd3-a0b1d3584305
@bkaradzic-microsoft
bkaradzic-microsoft force-pushed the pr/native-splat-matrix-storage branch from f720e88 to 09c9864 Compare October 1, 2026 16:42
@bkaradzic-microsoft
bkaradzic-microsoft enabled auto-merge (squash) October 1, 2026 22:14

@bghgary bghgary left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Reviewed by Copilot on behalf of @bghgary]

LGTM

@bkaradzic-microsoft
bkaradzic-microsoft merged commit 1e7f0d9 into BabylonJS:master Oct 1, 2026
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants